struct ListNode* reverseList(struct ListNode* head) {
    if (head == NULL)
    {
        return NULL;
    }
    if (head->next == NULL)
    {
        return head;
    }
    struct ListNode* cur = head->next;
    struct ListNode* prev = head;
    struct ListNode* after = head->next->next;
    prev->next = NULL;
    if (after == NULL)
    {
        cur->next = prev;
        return cur;
    }
    while (after != NULL)
    {
        cur->next = prev;
        prev = cur;
        cur = after;
        after = after->next;
    }
    cur->next = prev;
    return cur;
}